package com.pie4cloud.pie.bus.config;

import com.pie4cloud.pie.common.security.feign.PieFeignClientConfiguration;
import feign.Client;
import feign.Contract;
import feign.Feign;
import feign.codec.Decoder;
import feign.codec.Encoder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.openfeign.FeignClientsConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;


@Configuration
@Import({PieFeignClientConfiguration.class,FeignClientsConfiguration.class})
public class FeignRemote   {
	private  Feign.Builder urlBuilder;


	@Autowired
	public FeignRemote(Decoder decoder, Encoder encoder, Client client, Contract contract) {
		this.urlBuilder = Feign.builder().client(client)
				.encoder(encoder)
				.decoder(decoder)
				.contract(contract);
	}
	public <T> T target(Class<T> apiType,String sn){
		return this.urlBuilder.target(apiType,"http://"+sn);
	}

}
